This repository was archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
P1 345 woo shopping data in google preview #1118
Merged
JoseeWouters
merged 25 commits into
develop
from
P1-345-Woo-shopping-data-in-google-preview
Apr 12, 2021
Merged
P1 345 woo shopping data in google preview #1118
JoseeWouters
merged 25 commits into
develop
from
P1-345-Woo-shopping-data-in-google-preview
Apr 12, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…github.com/Yoast/javascript into P1-345-Woo-shopping-data-in-google-preview
igorschoester
suggested changes
Mar 31, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR 🏗️
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/SnippetPreview.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/SnippetPreview.js
Outdated
Show resolved
Hide resolved
igorschoester
suggested changes
Apr 7, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR 🏗️
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
Comment on lines
735
to
753
if ( shoppingData !== {} ) { | ||
|
||
if ( mode === MODE_DESKTOP ) { | ||
return ( | ||
<ProductDataDesktop | ||
shoppingData={ shoppingData } | ||
/> | ||
); | ||
} | ||
|
||
if ( mode === MODE_MOBILE ) { | ||
return ( | ||
<ProductDataMobile | ||
shoppingData={ shoppingData } | ||
/> | ||
); | ||
} | ||
|
||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things:
- You can not compare an object to an empty different object. It compares the memory address and thus will never be the same. You can work around this by checking if there are any values for example.
- You can early return on the shoppingData check so you don't have to indent for all the rest. This improves readability of your code.
- You are missing a return for when the shoppingData is empty, that will be
undefined
instead ofnull
in your current code. That is not a problem in behavior, but it is not correct.
Suggested change
if ( shoppingData !== {} ) { | |
if ( mode === MODE_DESKTOP ) { | |
return ( | |
<ProductDataDesktop | |
shoppingData={ shoppingData } | |
/> | |
); | |
} | |
if ( mode === MODE_MOBILE ) { | |
return ( | |
<ProductDataMobile | |
shoppingData={ shoppingData } | |
/> | |
); | |
} | |
return null; | |
if ( Object.values( shoppingData ).length === 0 ) { | |
return null; | |
} | |
if ( mode === MODE_DESKTOP ) { | |
return ( | |
<ProductDataDesktop | |
shoppingData={ shoppingData } | |
/> | |
); | |
} | |
if ( mode === MODE_MOBILE ) { | |
return ( | |
<ProductDataMobile | |
shoppingData={ shoppingData } | |
/> | |
); | |
} | |
return null; |
Co-authored-by: Igor <[email protected]>
…github.com/Yoast/javascript into P1-345-Woo-shopping-data-in-google-preview
igorschoester
approved these changes
Apr 7, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR 👍
Acceptance 👍 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
changelog: enhancement
Needs to be included in the 'Enhancements' category in the changelog
innovation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Test instructions
This PR can be tested by following these steps:
Impact check
UI changes
Quality assurance
Fixes P1-345